<%@page import="java.net.URLEncoder"%>
<%@page import="java.net.URLDecoder"%>
<%@page import="java.sql.ResultSet"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="database" scope="request" class="accessibleworldsdatabase.AccessibleWorldsDatabaseJavaBeans"/>
<jsp:useBean id="des" scope="request" class="accessibleworldsdes.AccessibleWorldsDESJavaBeans"/>
<%try {
	
String accessCode = request.getParameter("accessCode");

if(!(accessCode==null || "".equals(accessCode))) {
	
    accessCode = des.decryptString(session.getId(), accessCode);
    accessCode = URLDecoder.decode(accessCode, "UTF-8");

    if(des.getAndroidAccessCode().equals(accessCode) || des.getComputerAccessCode().equals(accessCode)) {
    	
        String reportID = request.getParameter("reportID");
        String status = request.getParameter("status");
        String type = request.getParameter("type");
        String title = request.getParameter("title");
        String description = request.getParameter("description");
                
        if(!(reportID==null || "".equals(reportID) || 
			title==null || "".equals(title) || description==null ||"".equals(description) ||
       		status==null ||"".equals(status) || type==null ||"".equals(type))) {
            
        	reportID = des.decryptString(session.getId(), reportID);
            status = des.decryptString(session.getId(), status);
            type = des.decryptString(session.getId(), type);
            title = des.decryptString(session.getId(), title);
            description = des.decryptString(session.getId(), description);
            
            reportID = URLDecoder.decode(reportID, "UTF-8");
            status = URLDecoder.decode(status, "UTF-8");
            type = URLDecoder.decode(type, "UTF-8");
            title = URLDecoder.decode(title, "UTF-8");
            description = URLDecoder.decode(description, "UTF-8");
            
            System.out.println(reportID);
            System.out.println(status);
            System.out.println(type);
            System.out.println(title);
            System.out.println(description);
            
            database.connect(des.decryptString(des.getServiceSecretKey(), database.getEncryptedPassword()));
            
            String SQL =
           	"UPDATE Reports"+
           		" SET"+
           			" status = \""+status+"\""+
           			",v_id = "+type+""+
           			",title = \""+title+"\""+
    				",description = \""+description+"\""+
				" WHERE"+
					" Report_Id = "+reportID;
            
            System.out.println(SQL);
            
			database.updateSQL(SQL);
            
			String output = URLEncoder.encode("OK","UTF-8");

			output = des.encryptString(session.getId(),output);
			out.print(output);

			database.closeConnection();
       }
    }
}
} catch (Exception ex) {}%>